/**
 * 
 */
package com.gwcloud.leetcode.hot100;

import java.util.ArrayList;
import java.util.List;

import com.gwcloud.leetcode.common.datastructure.TreeNode;

/**
 * @ClassName   : Leetcode0114 
 * @author      : ganwei 
 * @date        : 2020年5月20日
 * @Description : Leetcode0114
 */
public class Leetcode0114 {
	List<TreeNode> l = new ArrayList<TreeNode>();
    public void flatten(TreeNode root) {
    	firstView(root);
        for(int i = 0; i < l.size()-1; i++){
        	TreeNode node = l.get(i);
        	TreeNode node1 = l.get(i+1);
        	node.left = null;
        	node.right = node1;
        }
        
    }
    public void firstView(TreeNode root){
    	if(root == null){
    		return;
    	}
    	l.add(root);
    	firstView(root.left);
    	firstView(root.right);
    }
}
